package com.guitar.accounting.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.guitar.accounting.model.User;
import com.guitar.accounting.service.UserService;

@Controller
@RequestMapping(value = "/user.do")
public class UserController {
    
    @Autowired
    UserService userService;
    
    @ResponseBody
    @RequestMapping(params = "method=add")
    public String register(HttpServletRequest request, HttpServletResponse response){
        
        User user = new User();
        user.setAccount((String)request.getParameter("account"));
        user.setName((String)request.getParameter("name"));
        user.setPhone((String)request.getParameter("phone"));
        user.setEmail((String)request.getParameter("email"));
        userService.addUser(user);
        return null;
    }
}
